﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class startUp : Form
    {
        public startUp()
        {
            InitializeComponent();
        }

        private void okSetUp_Click(object sender, EventArgs e)
        {
            if (setUpDatePicker.Value <= DateTime.Now)
            {
                MiscChargePeriod miscCharge = new MiscChargePeriod();
                miscCharge.setStartDate(setUpDatePicker.Value.ToString("yyyy-MM-dd"));
                miscCharge.setEndDate(setUpDatePicker.Value.ToString("yyyy-MM-dd"));
                miscCharge.setMiscCharge(0);
                bool success = new MiscChargeController().addPeriod(miscCharge);
                if (success)
                {
                    MessageBox.Show("Set up successful.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Set up error occured!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("Please set date at a previous date.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
